package com.ktwlsoft.archivemanage.controller.dataProfile;

import com.ktwlsoft.archivemanage.domain.business.repositoryService.view.AnnualReportDataProfileRepositoryService;
import com.ktwlsoft.archivemanage.payload.Result;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.Year;

@RestController
@RequestMapping("/annualReport")
public class AnnualReportProfileController {


    private final AnnualReportDataProfileRepositoryService annualReportDataProfileRepositoryService;

    public AnnualReportProfileController(AnnualReportDataProfileRepositoryService annualReportDataProfileRepositoryService) {
        this.annualReportDataProfileRepositoryService = annualReportDataProfileRepositoryService;
    }

    @ApiOperation("未提交年度报送的立档单位列表")
    @GetMapping("/getReportUncommitedUnits")
    public ResponseEntity<?> getReportUncommitedUnits(@ApiParam("年度") @RequestParam String year){
        return ResponseEntity.ok(Result.ok(annualReportDataProfileRepositoryService.getReportCommitedUnitMapper().selectUncommitedUnits(year)));
    }

    @ApiOperation("年度报送进度")
    @GetMapping("/gerReportProgress")
    public ResponseEntity<?> gerReportProgress(@ApiParam("年度") @RequestParam Year year){
        return ResponseEntity.ok(Result.ok(annualReportDataProfileRepositoryService.getReportProgress(year)));
    }

    @ApiModelProperty("历年报送情况统计")
    @GetMapping("/getEachYearStatistic")
    public ResponseEntity<?> getEachYearStatistic() {
        return ResponseEntity.ok(Result.ok(annualReportDataProfileRepositoryService.getReportCommitedUnitMapper().getEachYearStatistic()));
    }
}
